//everything in this file was made by Travis Lamb A.2

#include <string>
#include <iostream>
#include <sstream>
#include "Time.h"

using namespace std;
bool Time::time_valid(int h, int m)
{
	if(h<0 || h>23)
		return false;
	if(m<0 || m>59)
		return false;
	else
		return true;
}

//default constructor (unused)
Time::Time(){}

//primary constructor
Time::Time(int h, int m)
{
	set_time(h,m);
}

//returns string
string Time::to_string_time()
{
	ostringstream oss;
	oss << "Hour " << hour << ", Minute " << minute;
	/*string temp;	//<-- bad/old code
	temp += "Hour ";
	temp.append(hour);
	temp += ", Minute ";
	temp.append(minute);
	//return  "Hour " + hour + ", Minute " + minute;
	return temp;*/
	return oss.str();
}

//checks validity and sets time
void Time::set_time(int h, int m)
{
	if(time_valid(h,m))	//insures valid time
	{
		hour = h;
		minute = m;
	}
	else
		cerr << "\n\nERROR: Improper time input.\n\n";
}
